#ifndef _CAMERA_H
#define _CAMERA_H

#include "SFML\Graphics.hpp"
#include "GameTime.h"
#include <memory>

class Camera
{
public:

	static Camera* getSingleton();
	static void cleanSingleton();

	void initialize(std::shared_ptr<sf::View> view, float speed);
	void setMapSize(sf::Vector2f& mapSize) { _mapSize = mapSize; }

	void move(sf::Vector2f& position);
	void moveToCenter(sf::Vector2f& position);

	void goTo(sf::Vector2f& position);
	void goToCenter(sf::Vector2f& position);

	void update();
	sf::Vector2i getPosition() 
	{ return sf::Vector2i(static_cast<int>(_position.x), static_cast<int>(_position.y)); }
	sf::Vector2i getTileOffset(int tileSize)
	{ return sf::Vector2i((int)_position.x % tileSize,  (int)(_position.y) % tileSize ); }
	sf::IntRect getTilebounds(int tileSize);

private:
	Camera(void);
	~Camera(void);

	static Camera* _instance;

	std::shared_ptr<sf::View> _view;
	sf::Vector2f _position;
	sf::Vector2f _target;
	sf::Vector2f _size;
	sf::Vector2f _mapSize;
	float _speed;
};

#endif // _CAMERA_H